layui.use(['form','layer','table','laytpl'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laytpl = layui.laytpl,
        table = layui.table;
       
       rendering ();
       function rendering(){
       	 $.ajax({
            type: "GET",
            headers: {
                token :  $.cookie('tokenA')
            },
            url: api+"exam/user/score/list",
            data: {
               pageSize:100,
               pageNum:1
            },
            success: function(result){
            	tableData = result.data.list;
            	console.log(tableData);
			   //新闻列表
			    var tableIns = table.render({
			        elem: '#userList',
			        data : tableData,
			        cellMinWidth : 95,
			        page : true,
			        height : "full-125",
			        limits : [10,15,20,25],
			        limit : 20,
			        id : "userListTable",
			        cols : [[
			            {field: 'discipline', title: '班级', minWidth:100, align:"center"},
			            {field: 'number', title: '学号', align:'center',sort: true},
			            {field: 'username', title: '姓名',  align:'center'},
			            {field: 'scores', title: '成绩', minWidth:200, align:'center',templet:function(d){
			                return '<a class="layui-red">'+d.scores+'</a>';
			            },sort: true},
			            {title: '操作', minWidth:175, templet:'#userListBar',fixed:"right",align:"center"}
			        ]]
			    });


                table.on('tool(userList)', function(obj){
			        var layEvent = obj.event,
			            rowData = obj.data;
			            console.log(rowData)
			        if(layEvent === 'detail'){ //编辑
			            openDetail(rowData);
			        }
			    });
     	
			    
			    function openDetail(edit){
			        var index = layui.layer.open({
			            title : "成绩信息详情",
			            type : 2,
			            area:["400px","300px"],
			            content : "score-order-detail.html",
			            success : function(layero, index){
			                var body = layui.layer.getChildFrame('body', index);
			                if(edit){
			                    body.find(".id").val(edit.id);
			                    body.find(".class").html(edit.discipline);
			                    body.find(".number").html(edit.number);
			                    body.find(".name").html(edit.username);
			                    body.find(".score").html(edit.scores);
			                    form.render();
			                }
			            }
			        });
			    }
			    
                            	
            }
        });

       }

});